package test2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class CatchGame {

    public static void main(String[] args) {
        StringBuffer buf = new StringBuffer();
        BufferedReader br = null;
        String cotent = null;

        try {
            URL url = new URL("www.baidu.com");//URL获得目标地址类
            URLConnection urlConnection = url.openConnection();//获得该抽象类的实例
            br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(),"UTF-8"));
            while ((cotent = br.readLine())!=null){
                buf.append(cotent);
                buf.append("\r\t");
            }
            System.out.println(buf.toString());
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                br.close();
                br = null;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }



}
